home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / yacas_alg / yacas_morphos / share / yacas / include / lispobject.inl < prev    next >
Encoding:
Text File  |  2002-03-13  |  1.6 KB  |  112 lines

  1.  
  2. #include "lispassert.h"
  3. #include "lisperror.h"
  4.  
  5.  
  6. inline void LispPtr::DestroyPrevious()
  7. {
  8.     if (iNext != NULL)
  9.     {
  10.         if (!iNext->DecreaseRefCount())
  11.     {
  12.             delete iNext;
  13. #ifdef YACAS_DEBUG
  14.             DecNrObjects();
  15. #endif
  16.         }
  17.     }
  18. }
  19.  
  20. inline void LispPtr::DoSet(LispObject* aNext)
  21. {
  22.     iNext = aNext;
  23.     if (iNext != NULL)
  24.         iNext->IncreaseRefCount();
  25. }
  26.  
  27. inline void LispPtr::Set(LispObject* aNext)
  28. {
  29.     DestroyPrevious();
  30.     DoSet(aNext);
  31. }
  32.  
  33.  
  34. inline LispPtr& LispObject::Next()
  35. {
  36.     return iNext;
  37. }
  38.  
  39. inline LispInt LispObject::operator==(LispObject& aOther)
  40. {
  41.     return Equal(aOther);
  42. }
  43.  
  44. inline LispInt LispObject::operator!=(LispObject& aOther)
  45. {
  46.     return !Equal(aOther);
  47. }
  48.  
  49. inline LispPtr::LispPtr()
  50. {
  51.     iNext = NULL;
  52. }
  53.  
  54. inline LispPtr::LispPtr(LispPtr& aOther)
  55. {
  56.     DoSet(aOther.Get());
  57. }
  58.  
  59. inline LispPtr::LispPtr(LispObject& aOther)
  60. {
  61.     DoSet(&aOther);
  62. }
  63.  
  64. inline LispPtr::~LispPtr()
  65. {
  66.     DestroyPrevious();
  67. }
  68.  
  69.  
  70. inline LispObject* LispPtr::Get() const
  71. {
  72.     return iNext;
  73. }
  74.  
  75.  
  76. inline LispObject* LispPtr::operator()()
  77. {
  78.     return iNext;
  79. }
  80.  
  81. inline LispPtr* LispIterator::Ptr()
  82. {
  83.     return iPtr;
  84. }
  85.  
  86. inline void LispPtr::GoNext()
  87. {
  88.     LISPASSERT(iNext != NULL);
  89.     Set(iNext->Next().Get());
  90. }
  91.  
  92.  
  93.  
  94. inline LispObject* LispIterator::operator()()
  95. {
  96.     return iPtr->Get();
  97. }
  98.  
  99. inline void LispIterator::GoNext()
  100. {
  101.     Check(iPtr->Get() != NULL,KLispErrListNotLongEnough);
  102.     iPtr = &(iPtr->Get()->Next());
  103. }
  104.  
  105. inline void LispIterator::GoSub()
  106. {
  107.     Check(iPtr->Get() != NULL,KLispErrInvalidArg);
  108.     Check(iPtr->Get()->SubList() != NULL,KLispErrNotList);
  109.     iPtr = iPtr->Get()->SubList();
  110. }
  111.  
  112.